import 'package:flutter/material.dart';
import 'package:xindong/routes/tab_chats/view/xindong_chat_intimate_cell.dart';
import 'package:xindong/widgets/container/xindong_empty_container.dart';
import 'package:xindong/widgets/container/xindong_getx_builder_container.dart';

import 'controller/xindong_intimate_vm.dart';

class XinDongChatIntimateYeMian extends StatefulWidget {
  const XinDongChatIntimateYeMian({super.key});

  @override
  State<XinDongChatIntimateYeMian> createState() => _XinDongChatIntimateYeMianState();
}

class _XinDongChatIntimateYeMianState extends State<XinDongChatIntimateYeMian> with AutomaticKeepAliveClientMixin {
  // 避免状态重置
  @override
  bool get wantKeepAlive => true;

  @override
  Widget build(BuildContext context) {
    super.build(context);
    return XinDongGetBuilder<XinDongIntimateVM>(builder: (viewClass) {
      return XinDongRefreshContainer(
        viewClass: viewClass,
        child: XinDongEmptyContainer(
          dataList: viewClass.dataList,
          emptyTips: "暂无亲密好友，多参与互动聊天吧",
          child: ListView.separated(
            controller: viewClass.scrollController,
            itemCount: viewClass.dataList?.length ?? 0,
            itemBuilder: (BuildContext context, int index) {
              final model = viewClass.dataList![index];
              return XinDongChatIntimateCell(model: model);
            },
            separatorBuilder: (BuildContext context, int index) {
              return const SizedBox(height: 1.0);
            },
          ),
        ),
      );
    });
  }
}
